/**
 * 
 */
package junit;

import es.uab.es2.TimeTracker.nucli.Projecte;
import es.uab.es2.TimeTracker.nucli.Rellotge;
import es.uab.es2.TimeTracker.nucli.Tasca;
import junit.framework.TestCase;

/**
 * @author sule
 *
 */
public class TestTasca extends TestCase {

    private static final long ONZEMIL = 11000;
    private static final long CUATREMIL = 4000;
    private static final Object CATORZEMIL = 14000;
    private Tasca tascaProva, tascaProva2;
    private Rellotge clock;
    private Projecte arrel;
  
   
    /* (non-Javadoc)
     * @see junit.framework.TestCase#setUp()
     */
    protected final void setUp() throws Exception {
        super.setUp();
        tascaProva = new Tasca(); 
        arrel = new Projecte();
        tascaProva2 = new Tasca("T1", "dd1", arrel, arrel.getActivitats());
       
        clock = Rellotge.getInstancia();
    }
    public final void testConometrar() throws Throwable {
        tascaProva.setProjectePare(null);
        tascaProva.setDurada(CUATREMIL);
        clock.iniciar();
        tascaProva.cronometrar("I2", "D2", clock);
        Thread.sleep(ONZEMIL);
        tascaProva.pararCronometre(clock);
        System.out.println(tascaProva.getDurada());
        assertEquals(tascaProva.getDurada(), CATORZEMIL);
        
    
    }
    public final void testConstructor() {
        
        assertEquals(tascaProva2.getNom(), "T1");
        assertEquals(tascaProva2.getDescripcio(), "dd1");
        assertEquals(tascaProva2.getProjectePare(), arrel);
        
    }
 
}
